<include file="Public/header" />
<title>添加账册</title>
</head>
<body>
<div class="pd-20">
<form class="" name="postForm" id="postForm" action="__URL__/index/"  enctype="multipart/form-data" method="post">
	<table class="table table-border table-bordered table-bg">
		<input type="hidden" name="id" class="input-text" value="<{$detail.id}>">
		<tbody>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">姓名</td>
				<td class="text-l" width="35%">
					<input type="text" name="name" class="input-text" value="<{$detail.name}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">身份证号</td>
				<td class="text-l" width="35%">
					<input type="text" name="no" class="input-text" value="<{$detail.no}>" >
				</td>				
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">省</td>
				<td class="text-l">
					<select name="province" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="province_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['province']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">市</td>
				<td class="text-l" width="35%">
					<select name="city" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="city_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['city']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">区/县</td>
				<td class="text-l">
					<select name="area" class="select input-text" style="width:250px;float:left;margin-right:5px;">
						<option value="0">---请选择---</option>
						<foreach name="area_list" item="vo">
							<option value="<{$vo['fullName']}>"<if condition="$vo['fullName'] eq $detail['area']">selected</if> ><{$vo.fullName}></option>
						</foreach>
					</select>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">详细地址</td>
				<td class="text-l">
					<input type="text" name="address" class="input-text" value="<{$detail.address}>" >
				</td>
			</tr>
			
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">身份证正面</td>
				<td class="text-l" width="35%">
					<input type="file" name="pic_f" class="input-text" value="" ><br>
					<img src="__ROOT__/<{$detail.pic_f}>" style="width:200px;cursor:pointer" class="ss" attr_val="1"/>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">身份证反面</td>
				<td class="text-l" width="35%">
					<input type="file" name="pic_b" class="input-text" value="" ><br>
					<img src="__ROOT__/<{$detail.pic_b}>" style="width:200px;cursor:pointer" class="ss" attr_val="1" />
				</td>				
			</tr>
			<tr class="text-c">
				<td width="15%" class="text-r" style="background-color:#f5f5f5">联系方式<br>(固话格式xxxx-xxxxxxx)</td>
				<td class="text-l" width="35%">
					<input type="text" name="tel" class="input-text" value="<{$detail.tel}>" >
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5"></td>
				<td class="text-l" width="35%">
				</td>				
			</tr>
		</tbody>
	</table>
	<input type="button" class="btn btn-primary radius mt" id="b_add" value="更新">
</form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js"></script>
<script type="text/javascript">
    $(function(){
		$(document).on('mousedown','.ss',function(){
			var this_ss=$(this);
			<!-- console.log($(this).attr('src')); -->
			if($(this).attr('attr_val')==1){
				$(this).attr('attr_val',2);
				var index=layer.open({
				  type: 1,
				  shade: false,
				  title: false, //不显示标题
				  closeBtn: 0, //不显示关闭按钮
				  area: ['600px'],
				  content: "<img src="+$(this).attr('src')+" style='width:600px;'/>"
				});
				$(document).on('mousedown','body',function(){
					this_ss.attr('attr_val',1);
					layer.close(index);
				});
			}
		});
		$("select[name=province]").change(function(){
				$.ajax({
					type: 'POST',
					data: {code:$(this).val()},
					url: "<{:U('city_list')}>",
					success:function(data){
						<!-- console.log(data.message.length); -->
						if(data.status==1){
							$("select[name=city]").find('option').remove();
							$("select[name=area]").find('option').remove();
							$("select[name=area]").append("<option value='0'>---请选择---</option>");
							$("select[name=city]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=city]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
			$("select[name=city]").change(function(){
				province_name=$("select[name=province]").find('option:checked').val();
				$.ajax({
					type: 'POST',
					data: {province_name:province_name,code:$(this).val()},
					url: "<{:U('area_list')}>",
					success:function(data){
						if(data.status==1){
							$("select[name=area]").find('option').remove();
							$("select[name=area]").append("<option value='0'>---请选择---</option>");
							for(i=0;i<data.message.length;i++){
								html="<option value='"+data.message[i].fullName+"'>"+data.message[i].fullName+"</option>";
								$("select[name=area]").append(html);
							}
						}else{			
							layer.msg(data.message);
						}
						return false;
					}
				})
			})
		/*保存计划入库单数据*/
		$("#b_add").click(function() { 
	        $("#postForm").ajaxSubmit({  
	            url: "<{:U('confirm_edit')}>",
	            type : "post",
	            dataType : 'json',  
	            success : function(data) {
					if(data.status==1){
						layer.msg(data.info,function(){
							parent.window.location.href =parent.window.location.href;
						});
					}else{
						layer.msg(data.info);
					}
	                
	            },  
	            error : function(data) {  
	                layer.msg('出错');
	            }  
	        });  
	    });

    })
</script>
</body>
</html>